package org.objective.dal.commands;

import org.common.service.ServiceRegister;
import org.objective.base.BaseTypeInfo;
import org.objective.command.AuthToken;
import org.objective.command.Command;
import org.objective.command.CommandResult;

import org.objective.command.VoidCommandResult;
import org.objective.service.DalService;
import static org.utils.fp.collection.CollectionFactory.*;

/**
 *
 * @author gus
 */
public class InsertTypeCommand implements Command
{
    private static final long serialVersionUID = 6306480815900543916L;
    private BaseTypeInfo typeInfo;

    public InsertTypeCommand(BaseTypeInfo typeInfo)
    {
        this.typeInfo = typeInfo;
    }

    @Override
    public Object[] getParameters()
    {
        return array(typeInfo);
    }

    @Override
    public CommandResult execute(ServiceRegister provider, AuthToken token) throws Exception
    {
        DalService service = provider.getService(DalService.class);
        service.insertType(typeInfo);
        return new VoidCommandResult();
    }
}
